package com.example.demo.request;


import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

//@Schema(description = "执行查询请求")
public class ExecuteQueryRequest {

    //@Schema(description = "要执行的SQL查询语句", example = "SELECT * FROM users LIMIT 10")
    @NotBlank(message = "SQL语句不能为空")
    private String sql;

    //@Schema(description = "返回结果的最大行数", example = "5", defaultValue = "5")
    @Min(value = 1, message = "限制行数必须大于0")
    @Max(value = 1000, message = "限制行数不能超过1000")
    private Integer limit = 5;

    //@Schema(description = "查询超时时间（秒）", example = "30", defaultValue = "30")
    @Min(value = 1, message = "超时时间必须大于0秒")
    @Max(value = 300, message = "超时时间不能超过300秒")
    private Integer timeoutSeconds = 30;

    // 构造函数
    public ExecuteQueryRequest() {}

    public ExecuteQueryRequest(String sql, Integer limit, Integer timeoutSeconds) {
        this.sql = sql;
        this.limit = limit;
        this.timeoutSeconds = timeoutSeconds;
    }

    // Getter和Setter方法
    public String getSql() {
        return sql;
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

    public Integer getLimit() {
        return limit;
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
    }

    public Integer getTimeoutSeconds() {
        return timeoutSeconds;
    }

    public void setTimeoutSeconds(Integer timeoutSeconds) {
        this.timeoutSeconds = timeoutSeconds;
    }

    @Override
    public String toString() {
        return "ExecuteQueryRequest{" +
                "sql='" + sql + '\'' +
                ", limit=" + limit +
                ", timeoutSeconds=" + timeoutSeconds +
                '}';
    }
}